package physics;

import org.jbox2d.dynamics.Body;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;

public class MyBrickBody extends MyBody{
	public int height;
	public int width;
	public MyBrickBody(Body body,int height,int width,Color color) {
		body.setUserData(this);
		this.body=body;
		this.color=color;
		this.width=width;
		this.height=height;
	}
	@Override
    public void drawSelf(Graphics2D canvas) { 
		canvas.setColor(color);
		int x=(int) body.getPosition().x;
		int y=(int) body.getPosition().y;
		
		AffineTransform transform=AffineTransform.getRotateInstance(body.getAngle(),x,y);
		
		canvas.setTransform(transform);
        Rectangle2D rect = new Rectangle2D.Double(x-(width/2), y-(height/2), width, height);
		canvas.draw(rect);
	}
}
